home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flread -- Read from a file to a buffer
- *
- * Synopsis ercode = flread(handle,pbufads,nbytes,pnread);
- * int ercode DOS function return error code
- * int handle File handle
- * ADS *pbufads Segment, offset address of input buffer
- * unsigned nbytes Number of bytes to read
- * unsigned *pnread Number of bytes actually returned
- *
- * Description flread transfers the specified number of bytes (nbytes)
- * from the file (whose handle is specified) to a buffer whose
- * segment and offset address is pointed to by pbufads. The
- * number of bytes actually read is also returned. The file
- * pointer is moved the number of bytes read; therefore,
- * successive calls to flread will sequentially read the file.
- *
- * Returns ercode DOS 2.0 function error code
- * pnread The number of bytes transferred to the
- * I/O buffer.
- *
- * Version 1.1 (C)Copyright Blaise Computing Inc. 1983, 1984
- *
- **/
- struct dreg
- {
- unsigned ax,bx,cx,dx,si,di,ds,es;
- };
- #define DOSREG struct dreg
-
- struct segads /* Segment,offset address type */
- {
- unsigned r;
- unsigned s;
- };
- #define ADS struct segads /* Abbreviation */
-
- int flread(handle,pbufads,nbytes,pnread)
- int handle;
- ADS *pbufads;
- unsigned nbytes,*pnread;
- {
-
- DOSREG dos_reg;
- int ercode,utinit(),dos();
-
- utinit(&dos_reg); /* Initialize the registers */
- dos_reg.ax = 0x3f00; /* DOS function 3F */
- dos_reg.bx = handle;
- dos_reg.cx = nbytes;
- dos_reg.dx = pbufads->r;
- dos_reg.ds = pbufads->s;
- ercode = dos(&dos_reg);
- *pnread = dos_reg.ax;
-
- return(ercode);
-
- }